﻿using AutoMapper;
using BackData;
using Domain.DTOs.排程;
using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Team.API.Applocation.Command.排程;

namespace Team.API.Controllers
{
    [Route("api/[controller]")]
    [ApiController]
    public class ProductionController : ControllerBase
    {
        private readonly IMediator mediator;

        public ProductionController(IMediator mediator)
        {
            this.mediator = mediator;
        }
        /// <summary>
        /// 创建计划表单
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<APIResult<int>> Handle(CreateProductionCommand request)
        {
            return await mediator.Send(request);
        }

        /// <summary>
        /// 处理获取生产计划请求
        /// </summary>
        /// <param name="request">获取生产计划命令</param>
        /// <param name="cancellationToken">取消令牌</param>
        /// <returns>生产计划分页结果</returns>
        [HttpGet]
        public async Task<APIPaging<ProductionDtos>> GetProduction()
        {
            GetProductionCommand request = new GetProductionCommand();
            return await mediator.Send(request);
        }
    }
}
